import request from '@/utils/request'
// import qs from 'qs'

// 自动备份

// 获取自动备份配置
export function getConfig (params) {
  var data = fromData(params)
  return request({
    url: '/autoBackup/getConfig',
    method: 'post',
    data
  })
}

// 下载
export function download (params) {
  var data = fromData(params)
  return request({
    url: '/autoBackup/download',
    method: 'post',
    responseType: 'blob',
    data
  })
}

// 修改自动备份配置
export function setConfig (params) {
  var data = fromData(params)
  return request({
    url: '/autoBackup/setConfig',
    method: 'post',
    data
  })
}

// 还原
export function reduction (params) {
  var data = fromData(params)
  return request({
    url: '/autoBackup/reduction',
    method: 'post',
    data
  })
}

// 删除
export function delBackup (params) {
  var data = fromData(params)
  return request({
    url: '/autoBackup/del_info',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
